package jk.wrapper.common.util;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import jk.wrapper.filters.NodeFilter;


public class ClassInfo {
	public static final Object create(Class clazz, Object[] params) {
		Class [] paramClasses = new Class[1];
		paramClasses[0] = Object.class;
		try {
			Constructor constructor = clazz.getDeclaredConstructor(paramClasses);
			constructor.setAccessible(true);
			return constructor.newInstance(params);
		} catch (Exception e) {
			throw new RuntimeException("class newInstance error : " + e);
		}
	}
	
	public static final Object create(Class clazz) {
		try {
			Constructor constructor = clazz.getDeclaredConstructor(new Class[]{});
			constructor.setAccessible(true);     
            return constructor.newInstance(new Object[] {});    
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return null;
	}
	
	public static final Class forNameToClass(String clazz) {
		Class retClass = null;
		try {
			retClass = Class.forName(clazz);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException("load class Exception: " + e);
		}
		return retClass;
	}
}
